]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
NetworkMenu: destroy More... submenu when empty
authorGiovanni Campagna <gcampagna@src.gnome.org>
Mon, 28 Mar 2011 19:27:03 +0000 (21:27 +0200)
committerDan Winship <danw@gnome.org>
Mon, 11 Apr 2011 14:38:00 +0000 (10:38 -0400)
Add a .length property to PopupMenuBase, and use it from the network
menu to destroy the menu when removing a network without rebuilding.

https://bugzilla.gnome.org/show_bug.cgi?id=645981

js/ui/popupMenu.js
js/ui/status/network.js

index 8f76ed6f051a23456516ea695319d5788a11b642..b1dcf498d79f85fc2000586dee7fc697aa9595f6 100644 (file)
@@ -766,6 +766,7 @@ PopupMenuBase.prototype = {
             this.box = new St.BoxLayout({ vertical: true });
         }
         this.box.connect_after('queue-relayout', Lang.bind(this, this._menuQueueRelayout));
+        this.length = 0;
 
         this.isOpen = false;
 
@@ -855,6 +856,8 @@ PopupMenuBase.prototype = {
             menuItem.connect('destroy', Lang.bind(this, function() {
                 menuItem.disconnect(menuItem._subMenuActivateId);
                 menuItem.disconnect(menuItem._subMenuActiveChangeId);
+
+                this.length--;
             }));
         } else if (menuItem instanceof PopupSubMenuMenuItem) {
             if (before_item == null)
@@ -871,6 +874,8 @@ PopupMenuBase.prototype = {
             this._connectItemSignals(menuItem);
         else
             throw TypeError("Invalid argument to PopupMenuBase.addMenuItem()");
+
+        this.length++;
     },
 
     getColumnWidths: function() {
index 752a9f6462333f43d0e8ac7ad6d38dfb729411c5..885c5d7936ebedd6777dc330a908605911a77467 100644 (file)
@@ -1198,6 +1198,11 @@ NMDeviceWireless.prototype = {
             if (apObj.item)
                 apObj.item.destroy();
             this._networks.splice(pos, 1);
+            if (this._overflowItem &&
+                this._overflowItem.menu.length == 0) {
+                this._overflowItem.destroy();
+                this._overflowItem = null;
+            }
         } else if (apObj.item)
             apObj.item.updateAccessPoints(apObj.accessPoints);
     },